#ifndef PINTAROS_H
# include "pintaros.h"
#endif

#include "response.h"

void ResponseManager(struct buffer_struct *tx_buffer, struct apdu_res_struct *apdu_res)
{
  int cnt;
  tx_buffer->length = 0;

  tx_buffer->buffer[0] = ((apdu_res->rsp_type) >> 8) & 0x00ff;
  tx_buffer->length++;

  if(apdu_res->rsp_xtra_param == 0)
    tx_buffer->buffer[1] = apdu_res->rsp_type & 0x00ff;
  else
    tx_buffer->buffer[1] = apdu_res->rsp_xtra_param;

  tx_buffer->length++;

  for(cnt = 0; cnt < apdu_res->rsp_data_len; cnt++) {
    tx_buffer->buffer[cnt+2] = apdu_res->rsp_data[cnt];
    tx_buffer->length++;
  }
}
